package lab01;

/**
 * Created by lenovo on 2017/9/28.
 */
public class Test03 {
    public static void main(String args[]){
        int i=1,sum=0;
        prafor(i,sum);
        prawhile(i,sum);
        pradowhile(i,sum);
    }
    public static void prafor(int i,int sum){
        System.out.print("for语句实现");
        System.out.println("1-100的和为：");
        for(i=1;i<=100;i++){
            sum=sum+i;
        }
        System.out.println("sum="+sum);
    }
    public static void prawhile(int i,int sum){
        System.out.print("while语句实现");
        while (i<=200) {
            i++;
            sum=sum+i;
        }
        System.out.println("1-200的和为：");
        System.out.println("sum="+sum);
    }
    public static void pradowhile(int i,int sum){
        System.out.print("do while语句实现");
        do {
            i++;
            sum=sum+i;
        }while (i<=200);
        System.out.println("1-200的和为：");
        System.out.println("sum="+sum);
    }
}
